<template>
  <a-row style="padding: 10px;">
    <a-col span="24">
      <a-table :dataSource="table.data" :columns="table.columns" :pagination="table.pagination"
               size="small" bordered :rowKey="record => (record.applicationName + record.controllerName + record.apiId)">
      </a-table>
    </a-col>
  </a-row>
</template>

<script>
  export default {
    name: 'Api',
    data () {
      return {
        table: {
          pagination: false,
          loading: false,
          data: [],
          columns: [
            {
              title: 'applicationName',
              dataIndex: 'applicationName',
              sorter: true,
              width: 150
            }, {
              title: 'controllerName',
              dataIndex: 'controllerName',
              width: 300
            }, {
              title: 'apiUrl',
              dataIndex: 'apiUrl',
              width: 300
            }, {
              title: '模块名称',
              dataIndex: 'modularName'
            }, {
              title: '描述',
              dataIndex: 'description',
              sorter: true
            }, {
              title: '操作',
              scopedSlots: {customRender: 'operation'}
            }
          ]
        }
      }
    },
    mounted () {
      this.searchList()
    },
    methods: {
      // 查询应用资源树
      searchList () {
        this.loading = true
        this.http.post('upmsApi', '/api/getApiTree').then((res) => {
          if (res.success) {
            this.table.data = res.rows
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
